const {createProxyMiddleware} = require('http-proxy-middleware');

/* 此处跨域时，如果出现 ECONNREFUSED 的错误，
且 telnet 172.30.169.2 8081 时 Connection refused，
可能是 beego-test 内部的 beego 进程未成功启动，进入容器内部手动启动即可 */

module.exports = function (app) {
    app.use(createProxyMiddleware('/app', {
        target: "http://172.30.169.2:8081/",
        pathRewrite: {'^/app': ''},
        changeOrigin: true
    }));
    app.use(createProxyMiddleware('/flask', {
        target: "http://172.30.169.2:5001/",
        pathRewrite: {'^/flask': ''},
        changeOrigin: true
    }));
};
